/*
ID:ning yusui
LANG:C++
TASK:range
*/
#include<fstream>
#include <algorithm>
using namespace std;
int i,j,n,dp[256][256];
int rangeCount[256];
char ch;
int main()
{
	ifstream fin("range.in");
	fin>>n;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			fin>>ch;
			if (ch=='0') dp[i][j]=0;
			else dp[i][j]=min(dp[i][j-1],min(dp[i-1][j],dp[i-1][j-1]))+1;
			++rangeCount[dp[i][j]];
		}
	}
	for (i=n-1;i>1;i--) rangeCount[i]+=rangeCount[i+1];
	ofstream fout("range.out"); 
	for (i=2;rangeCount[i];i++) fout<<i<<" "<<rangeCount[i]<<endl;
	return 0;
}